package com.chainyoung.trademarket.mvp.model;

import com.chainyoung.common.appcommon.entity.CommonList;
import com.chainyoung.common.di.scope.FragmentScope;
import com.chainyoung.common.integration.IRepositoryManager;
import com.chainyoung.common.mvp.BaseModel;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmtrade.api.TradeService;
import com.chainyoung.trademarket.api.MainService;
import com.chainyoung.trademarket.entity.Msg;
import com.chainyoung.trademarket.entity.MsgNum;
import com.chainyoung.trademarket.mvp.contract.MsgFragmentContract;

import java.util.List;
import java.util.TreeMap;

import javax.inject.Inject;

import io.reactivex.Flowable;

@FragmentScope
public class MsgFragmentModel extends BaseModel implements MsgFragmentContract.Model {

    @Inject
    public MsgFragmentModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public Flowable<MsgNum> updateMsgStatus(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(MainService.class)
                .updateMsgStatus(map)
                .compose(RxUtils.<MsgNum>handleResult());
    }

    @Override
    public Flowable<List<CommonList<Msg>>> getMsgList(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(MainService.class)
                .getMsg(map)
                .compose(RxUtils.<List<CommonList<Msg>>>handleResult());
    }
}
